From 4d36fab72a1da6dccf0ba7f8fca99450bcd45d4b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 29 Apr 2014 21:43:11 -0400 Subject: [PATCH] widget-factory: populate the second page more Add back a menubar example that was lost a while ago, and also include a searchbar and an infobar. --- demos/widget-factory/widget-factory.c | 72 +++- demos/widget-factory/widget-factory.ui | 469 ++++++++++++++++++++++++- 2 files changed, 527 insertions(+), 14 deletions(-) diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index 1e59b0d0ac..0be65c7b10 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -23,18 +23,6 @@ #include "config.h" #include -static void -activate_toggle (GSimpleAction *action, - GVariant *parameter, - gpointer user_data) -{ - GVariant *state; - - state = g_action_get_state (G_ACTION (action)); - g_action_change_state (G_ACTION (action), g_variant_new_boolean (!g_variant_get_boolean (state))); - g_variant_unref (state); -} - static void change_theme_state (GSimpleAction *action, GVariant *state, @@ -50,6 +38,44 @@ change_theme_state (GSimpleAction *action, g_simple_action_set_state (action, state); } +static void +change_toolbar_state (GSimpleAction *action, + GVariant *state, + gpointer user_data) +{ + GtkWidget *window = user_data; + GtkWidget *toolbar; + + toolbar = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "toolbar")); + gtk_widget_set_visible (toolbar, g_variant_get_boolean (state)); + + g_simple_action_set_state (action, state); +} + +static void +activate_search (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + GtkWidget *window = user_data; + GtkWidget *searchbar; + + searchbar = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "searchbar")); + gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (searchbar), TRUE); +} + +static void +activate_delete (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + GtkWidget *window = user_data; + GtkWidget *infobar; + + infobar = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "infobar")); + gtk_widget_show (infobar); +} + static void activate_about (GSimpleAction *action, GVariant *parameter, @@ -236,6 +262,13 @@ update_header (GtkListBoxRow *row, } } +static void +info_bar_response (GtkWidget *infobar, gint response_id) +{ + if (response_id == GTK_RESPONSE_CLOSE) + gtk_widget_hide (infobar); +} + static void activate (GApplication *app) { @@ -244,7 +277,10 @@ activate (GApplication *app) GtkWidget *widget; GtkAdjustment *adj; static GActionEntry win_entries[] = { - { "dark", activate_toggle, NULL, "false", change_theme_state } + { "dark", NULL, NULL, "false", change_theme_state }, + { "toolbar", NULL, NULL, "true", change_toolbar_state }, + { "search", activate_search, NULL, NULL, NULL }, + { "delete", activate_delete, NULL, NULL, NULL } }; builder = gtk_builder_new (); @@ -274,6 +310,16 @@ activate (GApplication *app) widget = (GtkWidget *)gtk_builder_get_object (builder, "listbox"); gtk_list_box_set_header_func (GTK_LIST_BOX (widget), update_header, NULL, NULL); + widget = (GtkWidget *)gtk_builder_get_object (builder, "toolbar"); + g_object_set_data (G_OBJECT (window), "toolbar", widget); + + widget = (GtkWidget *)gtk_builder_get_object (builder, "searchbar"); + g_object_set_data (G_OBJECT (window), "searchbar", widget); + + widget = (GtkWidget *)gtk_builder_get_object (builder, "infobar"); + g_signal_connect (widget, "response", G_CALLBACK (info_bar_response), NULL); + g_object_set_data (G_OBJECT (window), "infobar", widget); + gtk_widget_show_all (GTK_WIDGET (window)); g_object_unref (builder); diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui index 4aaefa16b1..66a8a6d71b 100644 --- a/demos/widget-factory/widget-factory.ui +++ b/demos/widget-factory/widget-factory.ui @@ -2031,7 +2031,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus. - + True False @@ -2188,8 +2188,475 @@ Suspendisse feugiat quam quis dolor accumsan cursus. True vertical + 10 + + + True + + + True + vertical + + + True + + + True + False + False + _File + True + + + True + False + + + _New + True + False + False + True + + + + + _Open + True + False + False + True + + + + + _Save + True + False + False + True + + + + + Save _As + True + False + False + True + + + + + True + False + False + + + + + _Quit + True + False + False + True + app.quit + + + + + + + + + True + False + False + _Edit + True + + + True + False + + + Cu_t + True + True + False + True + + + + + _Copy + True + False + False + True + + + + + _Paste + True + False + False + True + + + + + _Delete + True + False + False + True + win.delete + + + + + _Search + True + False + True + win.search + + + + + Checks & Radios + True + False + False + True + False + + + True + False + + + _Check + True + True + True + False + False + True + + + + + _Check + True + True + False + False + False + True + + + + + _Check + False + True + True + True + False + False + True + + + + + _Check + False + True + True + False + False + True + + + + + _Check + False + True + False + False + False + True + + + + + _Check + False + True + True + False + False + False + True + + + + + True + + + + + _Radio + True + True + True + False + False + True + + + + + _Radio + True + True + False + False + False + True + + + + + _Radio + False + True + True + True + False + False + True + + + + + _Radio + False + True + True + False + False + True + + + + + _Radio + False + True + False + False + False + True + + + + + _Radio + False + True + True + False + False + False + True + + + + + + + + + + + + + True + False + False + _View + True + + + True + False + + + _Dark theme + True + False + False + True + win.dark + + + + + _Toolbar + True + True + False + False + True + win.toolbar + + + + + + + + + True + False + False + _Help + True + + + True + False + + + _About + True + False + False + True + app.about + + + + + + + + + + + True + + + True + New + document-new + + + + + True + Save + document-save + + + + + True + Search + search + win.search + + + + + + + True + + + True + + + + + + + True + True + + + + + True + You wanted to delete something. + + + + + + + + + True + in + True + + + True + True + textbuffer1 + 2 + + + + + + + + + + + True + horizontal + + + + + True + horizontal + + + True + + + + + True + vertical + + + + + True + vertical + + + True + + + + + True + + -- 2.30.2